﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<html>
	<head>
		<title>Index</title>
		<script type="text/javascript" src="http://www.google.com/jsapi?hl=en"></script>
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
		<script type="text/javascript">
			/* <![CDATA[ */
			var ge;
			google.load('earth','1',{'other_params': 'sensor=false'});
			
			function init() {
				resize();
				window.onresize = resize;
				google.earth.createInstance("map3d", initCB, null);				
			}
			
			function initCB(instance) {
				ge = instance;
				
				fetchKml();
				
				ge.getWindow().setVisibility(true);
				ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
				
				
				// move camera
				var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
				
				lookAt.setLatitude(62.6604);
				lookAt.setLongitude(29.6151);
				lookAt.setRange(lookAt.getRange() / 4);
				
				ge.getView().setAbstractView(lookAt);
			}
			
			function resize() {
				var windowheight = $(window).height();
				if (windowheight < 3026) 
					$("#map3d_container").height(windowheight);
			}	
			/* ]]> */
		</script>
		
		<style type="text/css">
			html, body, form {margin:0px;border:0px;height:100%;font-size:11px;color:white;line-height:140px;overflow:hidden;}
			#map3d_container {height:395px;width:100%}
			#map3d {height:100%;width:100%;position:relative;}
		</style>
	</head>
	<body id="body" onload="init()">
		<div id="map3d_container">
			<div id="map3d"></div>
		</div>
	</body>
	
	<script type="text/javascript">
		var currentKmlObject = null;

		function fetchKml() {
			if (currentKmlObject) {
				ge.getFeatures().removeChild(currentKmlObject);
				currentKmlObject = null;
			}
			
			var kmlUrl = "https://plane-tracker.googlecode.com/svn/trunk/static/10_closest_flights.kml";
			google.earth.fetchKml(ge, kmlUrl, finishFetchKml);
		}
		
		function finishFetchKml(kmlObject) {
			if (kmlObject) {
				currentKmlObject = kmlObject;
				ge.getFeatures().appendChild(currentKmlObject);
			} else {
				setTimeout(function() { alert('Bad or null KML'); }, 0);
			}
		}
	</script>
</html>